<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.DriverManager" %><%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2018/4/8
  Time: 19:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>执行删除</title>
</head>
<body>

<%

    if (session.getAttribute("isLogin")==null){
        response.sendRedirect("login.jsp");
    }

    String id=request.getParameter("id");

    //链接数据库
    Connection connection=null;
    PreparedStatement preparedStatement=null;

    //注册数据库
    Class.forName("com.mysql.jdbc.Driver");

    //获取链接
    connection= DriverManager.getConnection("jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC",
            "root",
            "123456"
            );
    //数据库指令
    String sql="delete from t_users where id=?";

    //发送sql语句
    preparedStatement=connection.prepareStatement(sql);

    preparedStatement.setString(1,id);
//    preparedStatement.setInt(2,Integer.parseInt(id));

    preparedStatement.executeUpdate();

    connection.close();
    preparedStatement.close();
%>

</body>
</html>
